home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2002 May / CD Rom Data Mayıs 2002.iso / Freeware / Blitz Basic / data1.cab / Support / help / samples / tron.bb < prev    next >
Encoding:
Text File  |  2002-04-10  |  2.0 KB  |  92 lines

  1. Graphics 640,480
  2. SetBuffer BackBuffer()
  3.  
  4. Repeat
  5.  o1x=21
  6.  o1y=240
  7.  p1x=21
  8.  p1y=240
  9.  p1dir=1 ;right
  10.  o2x=618
  11.  o2y=240
  12.  p2x=618
  13.  p2y=240
  14.  p2dir=3 ;left
  15.  Color 255,255,255
  16.  Text 320,10,"Lightcycles",1,1
  17.  Text 320,30,"Written by Ed Upton",1,1
  18.  Text 320,150,"Player 1 controls: W-up X-down A-left D-right",1,1
  19.  Text 320,180,"Player 2 controls: Numpad 8-up 2-down 4-left 6-right",1,1
  20.  Text 320,400,"Press Enter to start",1,1
  21.  Flip
  22.  Repeat
  23.  Until KeyDown(28)=1 Or KeyDown(1)=1
  24.  If KeyDown(1)=1 Then End
  25.  Cls
  26.  Flip
  27.  Cls
  28.  Repeat
  29.   Color 255,255,255
  30.   Line 0,0,639,0
  31.   Line 0,0,0,479
  32.   Line 0,479,639,479
  33.   Line 639,0,639,479
  34.   Color 255,0,0
  35.   Plot p1x,p1y
  36.   Plot o1x,o1y
  37.   Color 0,0,255
  38.   Plot p2x,p2y
  39.   Plot o2x,o2y
  40.   o1x=p1x
  41.   o1y=p1y
  42.   o2x=p2x
  43.   o2y=p2y
  44.   If KeyDown(72) Then p2dir=0
  45.   If KeyDown(80) Then p2dir=2
  46.   If KeyDown(75) Then p2dir=3
  47.   If KeyDown(77) Then p2dir=1
  48.   If KeyDown(17) Then p1dir=0
  49.   If KeyDown(45) Then p1dir=2
  50.   If KeyDown(30) Then p1dir=3
  51.   If KeyDown(32) Then p1dir=1
  52.   If p1dir=0 Then p1y=p1y-1
  53.   If p1dir=1 Then p1x=p1x+1
  54.   If p1dir=2 Then p1y=p1y+1
  55.   If p1dir=3 Then p1x=p1x-1  
  56.  
  57.   If p2dir=0 Then p2y=p2y-1
  58.   If p2dir=1 Then p2x=p2x+1
  59.   If p2dir=2 Then p2y=p2y+1
  60.   If p2dir=3 Then p2x=p2x-1
  61.  
  62.   p1death=0
  63.   GetColor p1x,p1y
  64.   If ColorRed()>0 Or ColorGreen()>0 Or ColorBlue()>0 Then p1death=1
  65.   If p1x<1 Then p1death=1
  66.   If p1x>638 Then p1death=1
  67.   If p1y<1 Then p1death=1
  68.   If p1y>478 Then p1death=1
  69.   p2death=0
  70.   GetColor p2x,p2y
  71.   If ColorRed()>0 Or ColorGreen()>0 Or ColorBlue()>0 Then p2death=1
  72.   If p2x<1 Then p2death=1
  73.   If p2x>638 Then p2death=1
  74.   If p2y<1 Then p2death=1
  75.   If p2y>478 Then p2death=1
  76.   Color 255,255,255
  77.   If p1death=1
  78.    Text 320,240,"Player 1 crashed",1,1
  79.    Flip
  80.    Delay 5000
  81.   EndIf
  82.   If p2death=1
  83.    Text 320,240,"Player 2 crashed",1,1
  84.    Flip
  85.    Delay 5000
  86.   EndIf
  87.   Flip
  88.  Until KeyDown(1)=1 Or p1death=1 Or p2death=1
  89.  If p1death=0 And p2death=0 Then End
  90. Until p1death=0 And p2death=0
  91. End
  92.